﻿Public Class CPekerjaan
    Inherits CContext

    Private INSERT_COMMAND As String
    Private UPDATE_COMMAND As String
    Private DELETE_COMMAND As String
    Private SELECT_COMMAND As String

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub simpan(ByVal nama As String)
        Me.INSERT_COMMAND = "INSERT INTO TBL_PEKERJAAN (NAMA) VALUES ('" & nama & "')"
        MyBase.InsertData(INSERT_COMMAND)
    End Sub

    Public Sub rubah(ByVal nama As String, ByVal idPekerjaan As Integer)
        Me.UPDATE_COMMAND = "UPDATE TBL_PEKERJAAN SET NAMA='" & nama & "'WHERE ID=" & idPekerjaan
        MyBase.UpdateData(UPDATE_COMMAND)
    End Sub

    Public Sub hapus(ByVal idPekerjaan As Integer)
        'validasi
        If idPekerjaan > 0 Then
            Me.DELETE_COMMAND = "DELETE FROM TBL_KELAS WHERE ID=" & idPekerjaan
            MyBase.DeleteData(DELETE_COMMAND)
        Else
            Throw New Exception
        End If
    End Sub

    Public Function getAll() As DataTable
        Me.SELECT_COMMAND = "SELECT * FROM TBL_PEKERJAAN"
        Return MyBase.SelectData(SELECT_COMMAND)
    End Function

End Class
